package deprecated;

import test.fingers.Bid;
import test.fingers.R;
import test.fingers.R.id;
import test.fingers.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.TextView;

public class Deal extends Activity{
	private boolean validHand;
	private int numCards;

	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.deallayout);

		final EditText numDealBox = (EditText) findViewById(R.id.cardsToDealTextBox);
		validHand = false;
		numCards = 3;

		numDealBox.setOnKeyListener(new OnKeyListener(){
			public boolean onKey(View v, int keyCode, KeyEvent event){
				String str = numDealBox.getText().toString();
				if(str.equals("1") || str.equals("0") || str.equals("2") || str.equals("")){
					numDealBox.setText("");
					validHand = false;
					numCards = 3;
				}else{
					validHand = true;
					numCards = Integer.parseInt(str);
				}

				// If the event is a key-down event on the "enter" button
				if((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER) && validHand){
					goToBid();
					return true;
				}

				return false;
			}
		});

		// this sets up a click listener for the continue button
		findViewById(R.id.dealContButton).setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(validHand)
					goToBid();
			}
		});
	}

	private void goToBid(){
		Intent i = new Intent(this, Bid.class);
		startActivity(i);
	}
}
